package com.zifeng.study.controller;

import com.zifeng.study.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 吴梓锋
 * @version 1.0.0
 * @date 2022/06/05 17:06:51
 * @description 订单controller
 */
@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    OrderService orderService;

    @ResponseBody
    @RequestMapping("/create")
    public Map<String, Object> create(@RequestParam("userId") long userId, @RequestParam("productName") String productName) {
        String result = orderService.createOrder(userId, productName);

        Map<String, Object> response = new HashMap<>();
        response.put("code", "200");
        response.put("status", "success");
        response.put("result", result);

        return response;
    }

}
